
package com.ruoyi.web.controller.lingshui.conpermit;


import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.sql.SqlUtil;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.supervise.domain.ConstructionPermit;
import com.ruoyi.supervise.domain.ConstructionPermitChangeApply;
import com.ruoyi.supervise.domain.MyTest;
import com.ruoyi.supervise.service.IConstructionPermitChangeService;
import com.ruoyi.system.domain.SysUser;

import cn.hutool.core.util.StrUtil;

/**
 * @ClassName: ConstructionPermitChangeController
 * @Description: 施工许可变更管理controller
 * @Author wtj
 * @DateTime 2020年4月7日 下午3:30:44
 */
@Controller
@RequestMapping("/conpermit/conpermitchange")
public class ConstructionPermitChangeController extends BaseController{

	private String prefix = "lingshui/conpermit/changeExamine";
	
	@Autowired
    private IConstructionPermitChangeService constructionPermitChangeService;
	
	@RequiresPermissions("conpermit:conpermitchange:view")
	@GetMapping()
	public String projectAll()
	{
	    return prefix + "/constructionPermitChange";
	}
	
	/**
     * 查询核查信息列表
     */
    @RequiresPermissions("conpermit:conpermitchange:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ConstructionPermit constructionPermit)
    {
        startPage();
        // 获取当前的用户信息
        SysUser currentUser = ShiroUtils.getSysUser();
        if(!currentUser.getLoginName().equals("admin") && !currentUser.getLoginName().trim().equals("lingshui")) {
        	constructionPermit.setInChargeDepartmentGuid(currentUser.getDept().getGuid());
        }
        List<ConstructionPermit> constructionPermitList = constructionPermitChangeService.selectConPermitChangeExamineList(constructionPermit);
        return getDataTable(constructionPermitList);
    }
    
    @RequiresPermissions("conpermit:conpermitchange:apply")
    @GetMapping("/edit/{guid}")
    public String edit(@PathVariable("guid") String guid, ModelMap mmap)
    {
    	mmap.put("isclose", "false");
    	ConstructionPermitChangeApply cpca = constructionPermitChangeService.selectConPermitChangeExamineDetailByGuid(guid);
    	mmap.put("compactBeginDate", DateUtils.parseDate(cpca.getCompactBeginDate()));
    	mmap.put("reportDate", DateUtils.parseDate(cpca.getReportDate()));
    	mmap.put("cpca", cpca);
		return prefix + "/constructionPermitChangeApply";
    }
   
   @PostMapping("/editSave")
   @ResponseBody
   public AjaxResult editSave(@Validated MyTest user)
   {
	return null;
   }
}
